home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.lib;
-
- import sub_arctic.anim.*;
- import sub_arctic.input.*;
-
- import java.awt.Point;
-
- /**
- * A container class to move a collection of objects with under control of
- * an animation transition. See the animation agent for details about how
- * animation transitions work.
- *
- * @see sub_arctic.anim.animation_agent
- * @see sub_arctic.anim.animatable
- * @author Ian Smith
- */
- public class anim_mover_container
- extends shrink_wrap_container implements animatable {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Call this to setup a transition for this object. Note: you may call
- * this more than once... if you do so, it is possible that you could
- * have multiple active transitions. This is useful! However, be
- * aware that previous calls are not cancelled by this call.
- *
- * @param transition t the transition we schedule for this object.
- */
- public void set_transition(transition t) {
- /* tell the agent what we want */
- manager.animation.schedule_transition(t);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Construct a new sprite container. Initially, there is no transition
- * scheduled.
- *
- * @param int xpos initial x position of the container.
- * @param int ypos initial y position of the container.
- * @param interactor child child object to install under this container.
- */
- public anim_mover_container(int xpos, int ypos, interactor child)
- {
- super(xpos,ypos,0,false);
- setup_for_fixed_children(1);
- set_child(0,child);
- child.set_x(0);
- child.set_y(0);
- _cback_obj=null;
- }
-
- //had:
- //* @exception general PROPAGATED.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Construct a new sprite container with a callback. Initially, there is no
- * transition scheduled.<p>
- *
- * The callback object gets the callback with 0 value for start and a 1 value
- * for end. The callback_info in both cases is the transition being started
- * or stopped.
- *
- * @param int xpos initial x position of the container.
- * @param int ypos initial y position of the container.
- * @param interactor child child object to install under this container.
- * @param callback_object co object we make callbacks to.
- */
- public anim_mover_container(int xpos, int ypos, interactor child,
- callback_object co)
- {
- super(xpos,ypos,0,false);
- setup_for_fixed_children(1);
- set_child(0,child);
- child.set_x(0);
- child.set_y(0);
- _cback_obj=co;
- }
-
- //had:
- //* @exception general PROPAGATED.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Callback number for callback at start of transition. */
- public static final int START_TRANSITION_CALLBACK = 0;
-
- /** Callback number for callback at end of transition. */
- public static final int END_TRANSITION_CALLBACK = 1;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Handle start of animation transition. This transition is used to
- * position this object over time. This makes the start of trajectory
- * callback (#0).
- *
- * @param transition trans the transition object controlling this.
- * @param trajectory traj the trajectory it is working over.
- * @param double start_t start value along trajectory 0..1.
- * @param Object start_obj first data value out of trajectory (must be
- * a Point object).
- * @param event e event "causing" the animation.
- * @param Object user_info the information associated with then object
- * when the transition was scheduled.
- */
- public void start_transition(transition trans, trajectory traj,
- double start_t, Object start_obj, event e,
- Object user_info) {
- Point p=(Point)start_obj;
- if ((active_constraints() & X) == 0) set_x(p.x);
- if ((active_constraints() & Y) == 0) set_y(p.y);
- if (_cback_obj!=null) {
- _cback_obj.callback(this,e,START_TRANSITION_CALLBACK,trans);
- }
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Handle an animation step. This animation should be along a trajectory of
- * points, and is used to position this object.
- *
- * @param transition trans the transition object controlling this.
- * @param trajectory traj the trajectory it is working over.
- * @param double start_t start value of this step (within 0..1 overall)
- * @param Object start_obj start data value for this step (this must be
- * a Point object).
- * @param double end_t end value of this step (within 0..1 overall)
- * @param Object end_obj end data value for this step (this must be
- * a Point object).
- * @param event e event "causing" the animation.
- * @param Object user_info the information associated with then object
- * when the transition was scheduled.
- */
- public void transition_step(transition trans, trajectory traj,
- double start_t, Object start_obj,
- double end_t, Object end_obj,
- event e, Object user_info) {
-
- Point p=(Point)end_obj;
- if ((active_constraints() & X) == 0) set_x(p.x);
- if ((active_constraints() & Y) == 0) set_y(p.y);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Handle the end of animation transition. This animation should be along
- * a trajectory of points, and is used to position this object. This makes
- * the end of trajectory callback (#1).
- *
- * @param transition trans the transition object controlling this.
- * @param trajectory traj the trajectory it is working over.
- * @param double start_t start value of this step (within 0..1 overall)
- * @param Object start_obj start data value for this step (this must be
- * a Point object).
- * @param double end_t end value of this step (within 0..1 overall)
- * @param Object end_obj end data value for this step (this must be
- * a Point object).
- * @param event e event "causing" the animation.
- * @param Object user_info the information associated with then object
- * when the transition was scheduled.
- */
- public void end_transition(transition trans, trajectory traj,
- double start_t, Object start_obj,
- double end_t, Object end_obj,
- event e, Object user_info) {
- Point p=(Point)end_obj;
- if ((active_constraints() & X) == 0) set_x(p.x);
- if ((active_constraints() & Y) == 0) set_y(p.y);
- if (_cback_obj!=null) {
- _cback_obj.callback(this,e,END_TRANSITION_CALLBACK,trans);
- }
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * This is where we hold our callback object.
- */
- protected callback_object _cback_obj;
-
- /*
- * Callback object.
- * @return callback_object the object we make callbacks to at the start and
- * end of transitions.
- */
- public callback_object callback_obj() { return _cback_obj;};
-
- /*
- * Set the callback object.
- * @param callback_object co the new callback object.
- */
- public void set_callback_obj(callback_object co) { _cback_obj=co;};
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-